/* *****************************************************************************************
 
Made by www.Flashphoner.com, all rights reserved.
These sources can only be used for working with Flashphoner server.
If you want use this to create your own application (separate from Flashphoner server) � 
please contact support@flashphoner.com 

******************************************************************************************/

package com.flashphoner.api.management
{
	import com.flashphoner.Logger;
	import com.flashphoner.api.data.PhoneConfig;
	
	import flash.media.Camera;
	
	public class VideoControl
	{
		private static var videoControl:VideoControl;
		private var cam:Camera;
		private static const FPS:int=25;
		
		public function VideoControl()
		{
			if (PhoneConfig.VIDEO_ENABLED){
				cam = Camera.getCamera();
				cam.setMode(176,144,15,false);
				cam.setKeyFrameInterval(48);
				cam.setQuality(0,95);
				cam.setMotionLevel(0,2000);
			}			
		}
		
		public static function getInstance():VideoControl{
			if (videoControl == null){
				videoControl = new VideoControl();
			}
			return videoControl;
		}
		
		public function getCam():Camera{
			return cam;
		}
		
		public function changeFormat(format:String):void{
			Logger.info("VideoControl.changeFormat format: "+format);
			if ("cif"==format){
				cam.setMode(352,288,15,false);
			} else if ("qcif"==format) {
				cam.setMode(176,144,15,false);				
			} else {
				Logger.info("Unknown video format: "+format);
			}
		}
		
		public function changeCamera(camera:Camera):void{
			if (PhoneConfig.VIDEO_ENABLED){
				camera.setMode(176,144,15,false);
				camera.setKeyFrameInterval(48);
				camera.setQuality(0,95);
				camera.setMotionLevel(0,2000);	
				this.cam = camera;			
			}
		}
	}
}